]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dbusServices: Allow replacement
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 3 Feb 2022 00:57:46 +0000 (01:57 +0100)
committerMarge Bot <marge-bot@gnome.org>
Mon, 7 Feb 2022 18:44:34 +0000 (18:44 +0000)
The REPLACE flag we currently pass is useless, as replacing the service
is disallowed when not started with the ALLOW_REPLACEMENT flag.

Fix this by adopting a more standard pattern where replacement is always
allowed, but only actually requested when `--replace` is passed on the
command line.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2152>

js/dbusServices/dbusService.js

index 71b1e35d7e474c4fab6fbaa30b331bca9d2a51f4..3e2fde06afcf4392f5c888675babb082a6b9a247 100644 (file)
@@ -6,6 +6,8 @@ const Signals = imports.signals;
 
 const IDLE_SHUTDOWN_TIME = 2; // s
 
+const { programArgs } = imports.system;
+
 var ServiceImplementation = class {
     constructor(info, objectPath) {
         this._objectPath = objectPath;
@@ -167,9 +169,13 @@ var DBusService = class {
 
         this._service.register();
 
+        let flags = Gio.BusNameOwnerFlags.ALLOW_REPLACEMENT;
+        if (programArgs.includes('--replace'))
+            flags |= Gio.BusNameOwnerFlags.REPLACE;
+
         Gio.DBus.own_name(Gio.BusType.SESSION,
             this._name,
-            Gio.BusNameOwnerFlags.REPLACE,
+            flags,
             () => this._service.export(),
             null,
             () => this._loop.quit());